#include "TextureLoader.h"

TextureLoader::TextureLoader(ResourceManager* rm)
	:Component(COMP_TEXTURE_LOADER),
	m_resourceManager(rm)
{
}

TextureLoader::~TextureLoader(void)
{
}

void TextureLoader::AddedToObject()
{
	RequestMessage(MSG_LOAD_TEXTURE,&TextureLoader::Load);
}

void TextureLoader::Load(const Message& msg)
{
	string path;
	string name;
	ID3D11ShaderResourceView* rv=NULL;
	Texture::sPtr t;
	AuxUnGroupArgus(msg.p,name,path);
	SendMessage(MSG_CREATE_TEXTURE,AuxGroupArgus(path,&rv));
	if(rv==NULL)
		EXCEPTION("")
	t=boost::make_shared<Texture>(name,rv);
	m_resourceManager->AddResource(Resource::TEXTURE,name,boost::shared_dynamic_cast<Resource>(t));
}
